package com.wctj.api.web.config;

import com.wctj.api.security.filter.JwtParseHeaderFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author carol
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    /**
     * @Profile("local")
     * @return
     */
    @Bean
    public FilterRegistrationBean<JwtParseHeaderFilter> jwtParseHeaderFilterRegistrationBean() {
        FilterRegistrationBean<JwtParseHeaderFilter> registration = new FilterRegistrationBean<>(new JwtParseHeaderFilter());
        registration.setName("jwtParseHeaderFilterRegistrationBean");
        return registration;
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");

    }

}